// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import Axios from 'axios'
Vue.prototype.$axios = Axios

Vue.config.productionTip = false
//1、引入插件
import Vuex from 'vuex'
//2、安装插件
Vue.use(Vuex);
//2.5创建store
let store = new Vuex.Store({
//3、配置store中的数据/存/取
    state: {
        //所有公用的数据
        num: 30
    },
    getters: {
        //取state中的数据
        getNum(state){
            return state.num
        }
    },
    // 操作数据
    mutations: {
        addNum(state,payload){
            Axios.get('/')
            .then(res => {
                console.log(res);
            })
            state.num += payload.num;
        }
    }
})

//4、将这个store对象关联vue实例




/* eslint-disable no-new */
new Vue({
  el: '#app',
  store,
  components: { App },
  template: '<App/>'
})
